//
//  UIButton+AnimationImage.m
//  Perking
//
//  Created by longmin on 16/7/14.
//  Copyright © 2016年 tim. All rights reserved.
//

#import "UIButton+AnimationImage.h"

@implementation UIButton (AnimationImage)

/** 动态设置按钮图片 */
-(void)setAnimationBackgoundImage:(UIImage *)image {
    
    [self setBackgroundImage:image forState:UIControlStateNormal];
    CATransition *transitionAnimation = [CATransition animation];
    transitionAnimation.duration = 0.5;
    transitionAnimation.type = kCATransitionFade;
    transitionAnimation.subtype = kCATransitionFromTop;
    transitionAnimation.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut];
    transitionAnimation.fillMode = kCAFillModeForwards;
    [self.layer addAnimation:transitionAnimation forKey:nil];
}

@end
